from libraries.base.signalClasses.RVariable import *
from libraries.base.signalClasses.RMatrix import RMatrix
class Racomp(RMatrix): # R acomp class is created after using acomp function from package compositions
    convertToList = [RMatrix]
    def __init__(self, widget, data, checkVal = True):
        RMatrix.__init__(self, widget = widget, data = data, checkVal = False)
        
        if checkVal:
            if self.R('class('+self.RFunctionParam_x+')') == 'acomp':
                print 'ACOMP!!!'
            elif self.R('class('+self.RFunctionParam_x+')') == 'rcomp':
                print 'RCOMP!!!'
            elif self.R('class('+self.RFunctionParam_x+')') == 'aplus':
                print 'APLUS!!!'
            elif self.R('class('+self.RFunctionParam_x+')') == 'rplus':
                print 'RPLUS!!!'
            else:
                raise Exception('Not of an acomp class')
            
    def convertToClass(self, varClass):
        if varClass == RMatrix:
            return self._convertToMatrix()
        else:
            raise Exception, '%s Not A Known Type' % str(varClass)
        
    def _convertToMatrix(self):
        return RMatrix(self.widget, data = 'as.matrix(%s)' % self.getData())